//
//  VideoDetialVC.m
//  KeleAppProject
//
//  Created by 周岑 on 2018/1/21.
//  Copyright © 2018年 Cen Zhou. All rights reserved.
//

#import "VideoDetialVC.h"
#import "VideoDetialView.h"
#import "DownloadSelectView.h"
#import "CommentTableViewCell.h"
#import "InputView.h"
@interface VideoDetialVC ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;
@end

static NSString *commentCell = @"commentCell";
@implementation VideoDetialVC


- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:NO];
    
}

- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    [self loadSubviewsOnDetial];
    
    
}

- (void)loadSubviewsOnDetial{
    
    
    
    UIImageView *playImageView = [[UIImageView alloc]init];
    playImageView.backgroundColor = KLColor_B6;
    [self.view addSubview:playImageView];
    [playImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self.view);
        make.height.mas_equalTo(210*HEIGHT);
    }];
    
    VideoDetialView *detialView = [[VideoDetialView alloc]init];
    detialView.backgroundColor = [UIColor whiteColor];
    detialView.downDelegate = [RACSubject subject];
    [detialView.downDelegate subscribeNext:^(id x) {
        DownloadSelectView *downSelView = [[DownloadSelectView alloc]init];
        [self.view addSubview:downSelView];
        [downSelView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo([UIApplication sharedApplication].keyWindow);
        }];
    }];
    [self.view addSubview:detialView];
    [detialView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(playImageView.mas_bottom);
        make.left.right.equalTo(self.view);
        make.height.mas_equalTo(203*HEIGHT);
    }];
    
    [self.view addSubview:self.tableView];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(detialView.mas_bottom);
        make.left.right.equalTo(self.view);
        make.bottom.equalTo(self.view).offset(-44*HEIGHT);
    }];
    
    UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [backBtn setBackgroundImage:[UIImage imageNamed:@"icon_fanhui_baise"] forState:UIControlStateNormal];
    [self.view addSubview:backBtn];
    [[backBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
        [self.navigationController popViewControllerAnimated:YES];
    }];
    [backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(32*HEIGHT);
        make.left.equalTo(self.view).offset(15*WIDTH);
        make.width.mas_equalTo(30*WIDTH);
        make.height.mas_equalTo(25*HEIGHT);
    }];
    
    InputView *inputView = [[InputView alloc]init];
    inputView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:inputView];
    [inputView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(self.view);
        make.height.mas_equalTo(44*HEIGHT);
    }];
    
}



- (UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc]init];
        _tableView.backgroundColor = [UIColor whiteColor];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.showsVerticalScrollIndicator = NO;
        _tableView.showsHorizontalScrollIndicator = NO;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    }
    return _tableView;
}



#pragma mark  ---- tableView 的代理方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    CommentTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:commentCell];
    if (!cell) {
        cell = [[CommentTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:commentCell];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 222*HEIGHT;
}

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 222*HEIGHT;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
   
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
